Skip to content

Tests: update automation rules test suite for v2 model#12850

Draft
Copilot wants to merge 9 commits intohumitos/webhook-filters-v2from
copilot/sub-pr-12848
Draft

Tests: update automation rules test suite for v2 model#12850
Copilot wants to merge 9 commits intohumitos/webhook-filters-v2from
copilot/sub-pr-12848

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 17, 2026

The automation rules v2 PR consolidated RegexAutomationRule, WebhookAutomationRule, and VersionAutomationRule into a single AutomationRule model. This PR updates the test suite to match.

test_automation_rules.py

  • Replace all RegexAutomationRule/WebhookAutomationRule/VersionAutomationRule references with AutomationRule
  • Field renames: match_argversion_match_pattern, predefined_match_argversion_predefined_match_pattern, version_type (str) → version_types (list)
  • Action constants: VersionAutomationRule.ACTIVATE_VERSION_ACTIONAutomationRule.ACTIVATE_VERSION_ACTION, etc.
  • Webhook rules now use webhook_files_match_pattern=[...] (JSONField list) instead of match_arg; test_version_type_filtering tests match_version() instead of run() since version type gating is no longer inside run()
  • Renamed TestRegexAutomationRulesTestAutomationRuleVersionMatching, test_add_rule_regextest_add_rule

test_automation_rule_views.py

  • URL names: projects_automation_rule_regex_create/editprojects_automation_rule_create/edit
  • POST data fields updated to match new AutomationRuleForm (version_predefined_match_pattern, version_types, version_match_pattern)
  • Drop test_empty_custom_match / test_invalid_regex (form no longer validates these); add test_create_rule_with_webhook_filter covering the new webhook filter field
  • test_create_rule_default_description now asserts rule.description is None and rule.get_description() == "Activate version" (description is no longer persisted, derived at runtime)

test_githubapp_webhook.py

  • Replace WebhookAutomationRule/VersionAutomationRule imports with AutomationRule from readthedocs.projects.models
  • Rule fixtures updated: match_argwebhook_files_match_pattern=[...], version_typeversion_types=[...], VersionAutomationRule.TRIGGER_BUILD_ACTIONAutomationRule.TRIGGER_BUILD_ACTION
  • Add version_predefined_match_pattern=ALL_VERSIONS to all webhook rule fixtures
# Before
rule = get(RegexAutomationRule, match_arg="^release-.*", version_type=TAG, ...)
# After
rule = get(AutomationRule, version_match_pattern="^release-.*", version_types=[TAG], ...)

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Co-authored-by: humitos <244656+humitos@users.noreply.github.com>
Copilot AI changed the title [WIP] [DOC-12788] Migrate automation rules to single model Tests: update automation rules test suite for v2 model Mar 17, 2026
Copilot AI requested a review from humitos March 17, 2026 11:42
@humitos
Copy link
Copy Markdown
Member

humitos commented Apr 9, 2026

@copilot can you update this PR with the latest changes in base branch and update the tests, please?

Copilot AI and others added 2 commits April 9, 2026 12:20
… copilot/sub-pr-12848

Co-authored-by: humitos <244656+humitos@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 9, 2026

@copilot can you update this PR with the latest changes in base branch and update the tests, please?

Done in commit 4d82d1b94. Merged the latest humitos/webhook-filters-v2 changes and updated both test files to reflect the new model structure:

  • AutomationRule is now imported from readthedocs.projects.models
  • Custom regex tests use version_predefined_match_pattern=CUSTOM_MATCH + version_match_pattern=<regex>
  • Webhook tests use the new separate webhook_files_match_pattern=[...] (JSONField list) instead of the old webhook_filter + webhook_match_pattern fields
  • View tests updated with CUSTOM_MATCH sentinel and webhook_files_match_pattern

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community bot commented Apr 9, 2026

Documentation build overview

📚 dev | 🛠️ Build #32189469 | 📁 Comparing a42b6d6 against latest (50e8d78)

  🔍 Preview build  

Show files changed (2 files in total): 📝 2 modified | ➕ 0 added | ➖ 0 deleted
File Status
aws-temporary-credentials.html 📝 modified
tests.html 📝 modified

Comment thread readthedocs/rtd_tests/tests/test_automation_rules.py
Copy link
Copy Markdown
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Comment thread readthedocs/rtd_tests/tests/test_automation_rules.py
Comment on lines 172 to 173
if result:
assert rule.run(version) is True
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are currently doing return True inside .run() but we probably should remove that because we call it manually only when it's needed now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted — the callers in oauth/tasks.py don't use the return value from run(). Since that's a change to the model in the base branch (humitos/webhook-filters-v2), I'll leave it for that PR to decide whether to remove return True. The test line assert rule.run(version) is True here verifies the current behaviour; it can be dropped once return True is removed from the model.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 9, 2026

@copilot can you update this PR with the latest changes in base branch and update the tests, please?

Already up to date — the base branch (humitos/webhook-filters-v2) tip is at 12cd37e which was merged in commit e42bf01. No new changes to pull in.

@humitos
Copy link
Copy Markdown
Member

humitos commented Apr 9, 2026

@copilot the file readthedocs/oauth/tests/test_githubapp_webhook.py needs to be updated to use AutomationRule instead of WebhookAutomationRule or VersionAutomationRule. Note that we won't use those models anymore, so anything refering to those models should be updated.

…hookAutomationRule/VersionAutomationRule

Agent-Logs-Url: https://github.com/readthedocs/readthedocs.org/sessions/61e9ef60-f3ce-4615-b389-4ba26c5b5e4a

Co-authored-by: humitos <244656+humitos@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 9, 2026

@copilot the file readthedocs/oauth/tests/test_githubapp_webhook.py needs to be updated to use AutomationRule instead of WebhookAutomationRule or VersionAutomationRule. Note that we won't use ...

Done in commit 18bdf0b. Updated test_githubapp_webhook.py:

  • Import changed to from readthedocs.projects.models import AutomationRule (plus ALL_VERSIONS from readthedocs.builds.constants)
  • WebhookAutomationRuleAutomationRule in all 4 rule fixtures
  • VersionAutomationRule.TRIGGER_BUILD_ACTIONAutomationRule.TRIGGER_BUILD_ACTION
  • match_arg="docs/*.rst"version_predefined_match_pattern=ALL_VERSIONS, webhook_files_match_pattern=["docs/*.rst"]
  • match_arg="docs/**"version_predefined_match_pattern=ALL_VERSIONS, webhook_files_match_pattern=["docs/**"]
  • version_type=BRANCH/EXTERNALversion_types=[BRANCH/EXTERNAL]
  • Updated all docstrings to remove WebhookAutomationRule references

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants